Boolean Code Clarity - which style to use? [closed]

Posted by Anonymous on Stack Overflow See other posts from Stack Overflow or by Anonymous
Published on 2009-10-08T03:04:36Z Indexed on 2010/03/25 23:13 UTC
Read the original article Hit count: 299

Filed under:
|
|

I was wondering what style others' use when writing conditional statements that include boolean types. Currently I'm caught between using two styles.

bool foo;

if (foo == true)
if (foo)

if (foo == false)
if (!foo)

Obviously the first set is a bit more obvious. However, when combining conditions it could get a bit clunky.

if (foo == true || blah == false || abc == true)
if (foo || !blah || abc)

Switching between one style for short conditionals and the other for long conditionals seems like inconsistent coding so it seems like I'd have to choose between one or the other. What do you prefer or consider better style and why?

© Stack Overflow or respective owner

Related posts about c++

Related posts about subjective